home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb / sprite / m68k_procDebugRegs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-20  |  2.5 KB  |  98 lines

  1. /* 
  2.  * procDebugRegs.c --
  3.  *
  4.  *    Convert registers between the format expected by the ptrace system
  5.  *    call and that of the Sprite Proc_Debug call.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.2 89/01/07 04:12:18 rab Exp $ SPRITE (Berkeley)";
  19. #endif /* not lint */
  20.  
  21. #include "sprite.h"
  22. #include "status.h"
  23. #include "sys/ptrace.h"
  24. #include <errno.h>
  25. #include <proc.h>
  26. #include <signal.h>
  27. #include <sys/wait.h>
  28. #include "sun3.md/reg.h"
  29. #include "procDebugRegs.h"
  30.  
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * procDebugToPtraceRegs --
  36.  *
  37.  *    Convert registers from a proc debug format to a ptrace format.
  38.  *
  39.  * Results:
  40.  *    None.
  41.  *
  42.  * Side effects:
  43.  *    None.
  44.  *
  45.  *----------------------------------------------------------------------
  46.  */
  47.  
  48. void
  49. procDebugToPtraceRegs(regStatePtr, ptraceRegsPtr)
  50.     Mach_RegState    *regStatePtr; /* Register state as returned by 
  51.                        * the PROC_GET_DBG_STATE argument
  52.                        * to Proc_Debug. */
  53.     char    *ptraceRegsPtr;          /* Memory to put ptrace format of
  54.                        * registers. */
  55.  
  56. {
  57.     register struct regs *regs = (struct regs *) ptraceRegsPtr;
  58.  
  59.     regs->r_pc = regStatePtr->pc;
  60.     regs->r_sr = regStatePtr->statusReg;
  61.     bcopy ((char *)&(regStatePtr->regs), (char *) &(regs->r_dreg),
  62.                     MACH_NUM_GPRS*sizeof(int));
  63.  
  64. }
  65.  
  66.  
  67. /*
  68.  *----------------------------------------------------------------------
  69.  *
  70.  * ptraceToProcDebugRegs --
  71.  *
  72.  *    Convert registers from a ptrace format to a proc debug format.
  73.  *
  74.  * Results:
  75.  *    None.
  76.  *
  77.  * Side effects:
  78.  *    None.
  79.  *
  80.  *----------------------------------------------------------------------
  81.  */
  82.  
  83. void
  84. ptraceToProcDebugRegs(ptraceRegsPtr, regStatePtr)
  85.     char    *ptraceRegsPtr;          /* Memory image of ptrace format of
  86.                        * registers. */
  87.     Mach_RegState    *regStatePtr; /* Register state as used by Proc_Debug */
  88.  
  89. {
  90.     register struct regs *regs = (struct regs *) ptraceRegsPtr;
  91.  
  92.     regStatePtr->pc = regs->r_pc;
  93.     regStatePtr->statusReg = regs->r_sr;
  94.     bcopy ((char *) &(regs->r_dreg), (char *)&(regStatePtr->regs), 
  95.                     MACH_NUM_GPRS*sizeof(int));
  96. }
  97.  
  98.